package circular_buffer;

public class ConsumerRunnable implements Runnable {

	public static final int DELAY = 0;
	public static final int COUNT_MESSAGES = 10;
	private CircularBuffer<String> buffer;
	private int id;
	
	public ConsumerRunnable(int id, CircularBuffer<String> buffer) {
		this.id = id;
		this.buffer = buffer;
	}
	
	@Override
	public void run() {
		for (int i=0; i<COUNT_MESSAGES; i++) {
			String message = buffer.get();
			System.out.println(id+" Consumer get: "+message);
			try {
				Thread.sleep(DELAY);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
